<#import "../macro/components.ftl" as components/>
<#include "../macro/layout_default.ftl"/>

<@head>
<link rel="stylesheet" href="/misc/app/css/product_list.css"/>
</@head>

<@body>
<script src="/misc/app/js/lgsNode_list.js"></script>
</@body>

<@layout_default>
<div class="box">
    <div class="box-header with-border">
        <span class="pull-right text-muted">共 ${lgsNodeList.resultTotal} 条记录</span>
        <form class="form-inline" action="/lgsNode">
            <div class="input-group">
                <div class="input-group-addon">关键字</div>
                <input type="text" class="form-control" style="width: 260px" name="name" value="${name!}" placeholder="类型名称"/>
            </div>
            <div class="input-group">
                <div class="input-group-addon">流向类型</div>
                <select class="form-control" name="type">
                    <option value="">全部</option>
                    <option value="1" ${(type?exists && type == 1)?string("selected","")}>出库</option>
                    <option value="2" ${(type?exists && type == 2)?string("selected","")}>入库</option>
                </select>
            </div>
            <div class="input-group">
                <div class="input-group-addon">状态</div>
                <select class="form-control" name="sta">
                    <option value="">全部</option>
                    <option value="1" ${(sta?exists && sta == 1)?string("selected","")}>正常</option>
                    <option value="0" ${(sta?exists && sta == 0)?string("selected","")}>停用</option>
                </select>
            </div>
            <button type="submit" class="btn btn-warning"><i class="fa fa-search"></i> 查询</button>
            <button type="button" id="search_reset" class="btn btn-warning"><i class="fa"></i> 重置</button>
            <button type="button" class="btn btn-default" name="btn_new_lgsNode" data-toggle="modal" data-target="#md_new_lgsNode"><i class="fa fa-plus"></i> 新增类型</button>
        </form>
        
    </div>

    <!-- /.box-header -->
    <div class="box-body">
        <table class="table table-striped table-hover">
            <tr>
                <th>ID</th>
                <th>类型名称</th>
                <th>流向类型</th>
                <th>ERP适用单据</th>
                <th>状态</th>
                <th>录入时间</th>
                <th>录入人</th>
                <th>操作</th>
            </tr>
            <#if (lgsNodeList.result?size > 0)>
                <#list lgsNodeList.result as item>
                    <tr>
                        <td>${item.id?c}</td>
                        <td>${item.name}</td>
                        <td>
                            <#if item.type?exists>
                                <#if item.type == 1>出库</#if>
                                <#if item.type == 2>入库</#if>
                            </#if>
                        </td>
                        <td>
                            <#if (item.bizList?size > 0)>
                                <#list item.bizList as it>
                                ${it.typename}
                                    <#if it_has_next>
                                        ,
                                    </#if>
                                </#list>
                            </#if>
                        </td>
                        <td>
                            <#if item.sta?exists>
                                <#if item.sta == 1>正常</#if>
                                <#if item.sta == 0>停用</#if>
                            </#if>
                        </td>
                        <td>${item.cTime?number_to_datetime}</td>
                        <td>${item.cAdmin}</td>
                        <td>
                            <button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#md_edit_lgsNode" data-lgsnode-id="${item.id?c}">编辑</button>
                        </td>
                    </tr>
                </#list>
            <#else>
                <tr>
                    <td class="text-center text-muted" colspan="8"><i class="fa fa-info-circle"></i> 没有记录</td>
                </tr>
            </#if>

        </table>
    </div>
    <!-- /.box-body -->
    <div class="box-footer text-center">
        <@components.pagination "/lgsNode?name=${name!}&type=${type!}&sta=${sta!}&page=$page",lgsNodeList.page,lgsNodeList.pageTotal/>
    </div>
</div>


<!--=========== Modals =============-->
<!-- md_new_product -->
<div class="modal" id="md_new_lgsNode" tabindex="-1">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title"><i class="fa fa-plus"></i> 新增类型</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" name="form_new_lgsNode">
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 类型名称</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" placeholder="" name="name" maxlength="50" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 流向类型</label>
                        <div class="col-sm-10" style="padding-top:7.5px">
                        	<input type="radio" name="type" id="radio_in" value="2" runat="server" />入库 &nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="radio" name="type" id="radio_out" value="1" runat="server" />出库
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">ERP适用单据:</label>
                        <div class="col-sm-10" style="padding-top: 5px;" id="new_biztype">
                        <#--<#list nodeList as item>-->
                                <#--<input type="checkbox" value="${item.id}" name="biztype"/> ${item.name}-->
                                <#--<#if (item_index?if_exists+1)%5 == 0> <br/> </#if>-->
                            <#--</#list>-->
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 类型状态</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="sta">
                                <option value="1">正常</option>
                                <option value="0">停用</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" name="btn_save_new_lgsNode">保存</button>
            </div>
        </div>
    </div>
</div>
<!-- md_new_product -->
<div class="modal" id="md_edit_lgsNode" tabindex="-1">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title"><i class="fa fa-pencil-square-o"></i> 编辑类型</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" name="form_edit_lgsNode">
                    <input type="hidden" name="id"/>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong>类型名称</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="name" maxlength="50" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 流向类型</label>
                        <div class="col-sm-10" style="padding-top:7.5px">
                        	<input type="radio" name="type" id="radio_in" value="2" runat="server" disabled />入库&nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="radio" name="type" id="radio_out" value="1" runat="server" disabled />出库
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">ERP适用单据:</label>
                        <div class="col-sm-10" style="padding-top: 5px;" id="edit_biztype">
                            <#--<#list nodeList as item>-->
                                <#--<input type="checkbox" value="${item.id}" name="biztype"/> ${item.name}-->
                                <#--<#if (item_index?if_exists+1)%5 == 0> <br/> </#if>-->
                            <#--</#list>-->
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 类型状态</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="sta">
                                <option value="1">正常</option>
                                <option value="0">停用</option>
                            </select>
                        </div>
                    </div>
                    
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" name="btn_save_edit_lgsNode">保存</button>
            </div>
        </div>
    </div>
</div>

</@layout_default>